<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        上传健康信息
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/main.css" media="all">
    <script type="text/javascript" src="../lib/loading/okLoading.js"></script>
    <style>
        .imgs{display: none;}
    </style>

</head>
<body>
<div class="x-body" id="app">
    <form class="layui-form layui-form-pane" action="" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" value="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>供应商名称
                        </label>
                        <div class="layui-input-block">
                            <input type="text"  name="households" autocomplete="off" placeholder="请输入"
                                   class="layui-input" value="" v-model="id">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" >
                            <span class='x-red'>*</span>电话
                        </label>
                        <div class="layui-input-block">
                            <input list="optionList"  name="households" autocomplete="off" placeholder="请输入"
                                   class="layui-input" value="" v-model="docExcel">
                            <datalist id="optionList">
                                <option v-for="doctor in  doctorId" :value="doctor.name">{{doctor.name}}</option>
                            </datalist>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="add" lay-submit="" @click="upload()">
                        新增
                    </button>
                </div>
                <div style="height:100px;"></div>
            </div>

        </div>
    </form>
</div>
</form>
</div>
<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function(data){
            var buildings_name=$("input[name='buildings_name']").val();
            var households=$("input[name='households']").val();
            if(buildings_name==""){
                layer.msg('栋数名称不能为空！',{icon:5,time:2000});return false;
            }
            if(households==""){
                layer.msg('总户数不能为空！',{icon:5,time:2000});return false;
            }
            var data = data.field;
            $.ajax({
                type:"post",
                url:"xxx",
                data:data,
                dataType:"json",
                success:function(data){
                    if(data.status==1){
                        layer.msg(data.info, {icon: 6,time:2000},function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;
                    }
                    else{
                        layer.msg(data.info,{icon:5,time:2000});return false;
                    }
                }

            });

        });

    })
</script>

<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui.min.js"></script>
<script type="text/javascript" src="../js/vue/vue.js"></script>
<script type="text/javascript" src="../js/vue/qs.js"></script>
<script type="text/javascript" src="../js/vue/axios.js"></script>

<script type="text/javascript">
    let vm = new Vue({
        el : "#app",
        data:{
            id: '',
            docName:'',
            docJob:'',
            docTitle:'',
            docExcel:'',
            docSalary:'',
            docTel:'',
            doctorId : [],
            supplierName : [],
            doctor : []
        },
        mounted(){
            axios.post("/user/job/name").then(res=>{
                this.doctorId = res.data;
                console.log(res.data);
            })
        },
        methods : {
            upload(){
                axios.post("/user/supplier/insert",qs.stringify({name:this.id, tel:this.docExcel})).then( res =>{
                    if(res.data == "添加成功"){
                        alert("添加成功")
                    }else {
                        alert("添加失败")
                    }
                    console.log(res);
                })
            }
        }
    })
</script>

</body>
</html>
